﻿using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using SLS.ExClassLib.DataType;
using SLS.ExClassLib.Database;
using SLS.ExClassLib.Events;
using SLS.ExClassLib.Data;
namespace SLS.Base
{
    public partial class ExGRID 
    {
        public bool IsCheckDataQuality
        {
            get
            {
                if (((CheckBox)FindName("IsCheckDataQuality")).IsChecked == true)
                    return true;
                return false;
            }
        }
        public CollectionViewSource vwBaseTable
        {
            get
            {
                return (CollectionViewSource)(TryFindResource("vwBaseTable"));
            }
        }
        public override void CMDEXE_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            { 
                base.CMDEXE_TextChanged(sender, e);
            }
            catch (Exception ex)
            {
                throw;
            } 
        }
        public override ExDataRow commandNew(string SM, string KEYDEFTYPE, string GTPRE, string GTKEY, string KEYINSTANCETABLE)
        {
            ExDataRow row = null;
            try
            {
                row = base.commandNew(SM, KEYDEFTYPE, GTPRE, GTKEY, KEYINSTANCETABLE);
            }
            catch (Exception ex)
            {
                throw;
            }
            return row;
        }
        public override ExDataRow commandCopy(ExDataRow dwThis)
        {
            ExDataRow row = null;
            try
            {
                row = base.commandCopy(dwThis);
            }
            catch (Exception ex)
            {
                throw;
            }
            return row;
        }
        public override void commandDelete(ExDataRow dwThis)
        {
            try
            {
                base.commandDelete(dwThis);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public override void commandModify(ExDataRow dwThis)
        {
            try
            {
                base.commandModify(dwThis);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public override void commandInformation(ExDataRow dwThis)
        {
            try
            {
                base.commandInformation(dwThis);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public override void commandSave(ExDataRow dwThis)
        {
            try
            {
                 dwThis.OnSaveRecord(1); 
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DataSet setEvent = new DataSet();
                string hostaddress = "";
                if (vwBaseQueryCond.View == null)
                    return;
                DataRow dwThis = ((DataRowView)vwBaseTable.View.CurrentItem).Row;
                if (dwThis == null)
                    return;  
                setEvent = (DataSet)DataAccessService.Instance.ImportDataTable(setEvent, dwThis);
                SetUpTableBase(setEvent, IsCheckDataQuality);
                //DocumentManagement.Instance.SendJobForProcessing(setEvent, this, "Edit", false, IsCheckDataQuality);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public void btnEditProcessingRecord_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ViewDataSet.LoadProcessing(BaseTable);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public virtual void SetUpTableBase(DataSet setEvent, bool CheckDataQuality)
        {
            try
            {
                ViewDataSet.SetUpTableBase(setEvent, CheckDataQuality);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
       
    }
}
